#include <bits/stdc++.h>
#define gc getchar
#define pc putchar
#define pt printf
#define IL inline
using namespace std;
const int Mxn=2005;
int N,Ea[Mxn],Eb[Mxn],Fa[Mxn],Dep[Mxn],Col[Mxn],R[Mxn][Mxn];
int Ct,Hd[Mxn],Nt[Mxn<<1],To[Mxn<<1],Lm[Mxn<<1];
IL int _() {
	int x=0,f=0;char ch=gc();
	while(ch<'0'||ch>'9') f|=(ch=='-'),ch=gc();
	while(ch>='0'&&ch<='9') x=(x<<1)+(x<<3)+(ch^48),ch=gc();
	return f?-x:x;
}
IL void __(int x) {
	int stk[30],tp=0;
	if(x<0) x=-x,pc('-');
	do stk[++tp]=x%10,x/=10;while(x);
	while(tp) pc(stk[tp--]^48);
}
int Max(int x,int y) {return x>y?x:y;}
int Min(int x,int y) {return x<y?x:y;}
void Merge(int x,int y,int v) {
	Nt[++Ct]=Hd[x],To[Ct]=y,Lm[Ct]=v,Hd[x]=Ct;
}
void DFS(int x,int p,int r) {
	for(int v,i=Hd[x];i;i=Nt[i]) {
		if((v=To[i])^p) {
			R[r][v]=Min(R[r][x],Lm[i]);
			DFS(v,x,r);
		}
	}
}
void Build(int x) {
	Dep[x]=Dep[Fa[x]]+1;
	for(int v,i=Hd[x];i;i=Nt[i]) {
		if((v=To[i])^Fa[x]) {
			Fa[v]=x,Build(v);
		}
	}
}
void Paint(int x,int c) {
	Col[x]=c;
	for(int v,i=Hd[x];i;i=Nt[i]) {
		if((v=To[i])!=Fa[x]) {
			Paint(v,c);
		}
	}
}
int Calc() {
	int Res=0;
//	for(int i=1;i<=N;++i) pt("%d ",Col[i]);pc('\n');
	for(int i=1;i<=N;++i) {
		for(int k=1;k<i;++k) {
			if(Col[i]==Col[k]) Res+=R[i][k];
		}
	}
	return Res;
}
signed main() {
	freopen("tatooine.in","r",stdin);
	freopen("tatooine.out","w",stdout);
	N=_();
	for(int c,i=1;i<N;++i) {
		Ea[i]=_(),Eb[i]=_(),c=_();
		Merge(Ea[i],Eb[i],c),Merge(Eb[i],Ea[i],c);
	}
	for(int i=N;i;--i) R[i][i]=528,DFS(i,0,i);
//	for(int i=1;i<=N;++i) {
//		for(int k=1;k<i;++k) {
//			pt("[%d %d] %d\n",k,i,R[k][i]);
//		}
//	}
	Build(1);
//	pt("!!!");
	for(int i=1;i<N;++i) {
		if(Dep[Ea[i]]<Dep[Eb[i]]) swap(Ea[i],Eb[i]);
		Paint(Ea[i],1);
		__(Calc()),pc('\n');
		Paint(Ea[i],0);
	}
	return 0;
}
